<%@ page language="java" import="java.util.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/spring.tld"%>
<%
String loginid = request.getParameter("loginid");
Cookie[] cookies=request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
Cookie sCookie=null; 
String svalue=null; 
String sname=null; 
String cookieName = null;
String cookiepwd = null;
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String stylePath = basePath+"app/css/";
String imagePath = basePath+"app/images/";
if(null != cookies){
	for(int i=0;i<cookies.length;i++){    //用一个循环语句遍历刚才建立的Cookie对象数组
	sCookie=cookies[i];   //取出数组中的一个Cookie对象 
	sname=sCookie.getName(); //取得这个Cookie的名字
	svalue=sCookie.getValue(); //取得这个Cookie的内容
	if("chdname".equals(sname)){
		cookieName =  svalue;
	} 
	if("chdpwd".equals(sname)){
		cookiepwd =  svalue;
	} 
	}
}
boolean flag = false;
if(null == cookieName){ 
    cookieName = (String)request.getAttribute("username");
}else{
	flag = true;
}
if(null!= loginid && !"".equals(loginid)){
    cookieName = loginid;
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<!-- common start  -->
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title><spring:message code="sys.name" /></title> 

<script  src="<%=basePath %>common/javascript/common.js"></script>
<script  src="<%=basePath %>common/javascript/check.js"></script>
<script src='<%=basePath%>dwr/engine.js'></script>
<script src='<%=basePath%>dwr/util.js'></script> 
<script src='<%=basePath%>common/javascript/grap.js'></script> 
<!-- common end  -->
<!-- custom start  -->
<link rel="stylesheet" type="text/css" href="<%=stylePath%>layout.css"/>
<% 
  String info = (String)request.getAttribute("alert");
  if(null == info)
     info = "";
  String userName = (String)request.getAttribute("username");
  if(null == userName){
     if(null != cookieName){
     	userName = cookieName;
     }else{
     	userName = "";
     }
  }
  session.invalidate();
%>
<script language=JavaScript>
 <!--
if(self != top) top.location.href = window.location.href;
//-->
function checkform()
{
if(isNull(document.LoginForm.UserName.value)){
  alert("请输入用户名～！");
  document.all.UserName.focus();
  return false;
}
if(isNull(document.LoginForm.Password.value)){
  alert("请输入密码～！");
  document.all.Password.focus();
  return false;
}
return true;
}
function isNull(pvalue)
 {
   var RegularExp=/^\s*$/;
   if(RegularExp.test(pvalue))
   {
     return true;
   }
   return false;
 }
function submitPage(){
    var LoginForm = document.forms[0];
    if(checkform()){
       LoginForm.submit();
    }
	
}
function isEntry(e){
     if(document.all)e = event;
     if(e.keyCode==13) {
             submitPage();
     };
}
function reguser(){
	document.location.href = "<%=basePath%>auth/userreg.do";

}
</script>
</head>
<body class="login_body">
<div class="login_parent"> 
    <form name="LoginForm" action="<%=basePath %>logon.do"  method="post"> 
        用户名<span class="c_bor"><input type="text" class="form_off" onfocus="this.className='form_on'" value="<%=cookieName==null?"":cookieName %>" name="UserName" id="UserName" onblur="this.className='form_off'" style="width:145px;"/></span>
        <div>密　码<span class="c_bor"><input type="password" class=" form_off" onfocus="this.className='form_on'" name="Password" value="<%=cookiepwd==null?"":cookiepwd %>" id="Password" onblur="this.className='form_off'" style="width:145px;"/></span></div>
        <p><input name="rememberme" type="checkbox"  value="1" <%if(flag){out.println(" checked");} %>/> 记住用户名密码        
        
        <br/> 
         <a href="javaScript:openwindow('<%=basePath %>app/task/online/handbook.doc','','','')"><font color=red><strong>使用手册及常见问题下载</strong></a>
        <font color=red><strong><%=info%></strong></font>
        <br/>
        <input type="button" class="login" onclick="submitPage();" value="登录"/><input type="button" class="regis" onclick="reguser();" value="注册"/></p>
  </form>
    <div class="copy_right"><spring:message code="sys.copyright" /></div>
</div>
</body>
</html>